﻿/// <reference path="jquery-1.8.2.js"/>

(function ($) {
    $.getQuerystring = function () {
        var indexof = window.location.href.indexOf('?');

        if (indexof > -1) {
            return window.location.href.slice(indexof + 1);
        }
        return '';
    };

    $.getUrlVars = function (querystring) {
        var vars = [], hash;

        if (querystring == null) {
            querystring = $.getQuerystring();
        }

        var hashes = querystring.split('&');
        for (var i = 0; i < hashes.length; i++) {
            hash = hashes[i].split('=');
            vars.push(hash[0]);
            vars[hash[0]] = hash[1];
        }
        return vars;
    };

    $.getUrlVar = function (parameter) {

        var querystring = $.getQuerystring();

        var hashes = querystring.split('&');
        
        for (var i = 0; i < hashes.length; i++) {
            var hash = hashes[i].split('=');
            if (hash[0] == parameter) {
                return hash[1];
            }
        }
        
        return null;
    };

})(jQuery);
